#include<iostream>
using namespace std;
const int N = 1e5 + 10;
string s;
int st[30];
bool is_ok()
{
	int cnt = 0;
	for (int i = 1; i <= 26; i++) {
		cnt += (st[i] >= 1);
	}
	return cnt == 26;
}
int main()
{
	cin >> s;
	int j = 0;
	int ans = 1e9;
	for (int i = 0; i < s.size(); i++) {
		int k = s[i] - 'a' + 1;
		st[k]++;
		while (is_ok()) {
			ans = min(i - j + 1, ans);
			int k = s[j] - 'a' + 1;
			st[k]--;
			j++;
		}
	}
	cout << ans << endl;
	return 0;
}